<?php
chdir("../");
header("content-type: text/html; charset=utf-8");
require "../config/config.php";
require "../config/attributes.php";
require GALAXYTOOL_ROOT."/secret/includes/authorization.inc.php";
session_start();
$NO_PAGE_FORWARD = true;
require GALAXYTOOL_ROOT."/secret/includes/logincheck.inc.php";
if (isset($error_page_code) && $error_page_code == "timeout") exit("");
require GALAXYTOOL_ROOT."/secret/includes/userinfo.inc.php";

if (!isset($_SESSION['lang']))
	$_SESSION['lang'] = $default_language;
Galaxytool::load_language_file($_SESSION['lang']);

try {
	$userinfo_obj = new UserInfo($global_mysql_con, $dbtablename, $systemtablename, $utablename, $reporttable, $iptablename, $fleetmovetable, $combattable, $messagetable, $playertable, $allytable);
} catch (Exception $e) {
	exit($e->getMessage());
}
?>
<script type="text/javascript">
var storeData3 = {
	identifier: 'id',
	label: 'username',
	items: [
<?php
	$content = $userinfo_obj->getSystemInfoData();
	$first_item = true;
	$number_of_items = count($content);
	foreach($content as $entry) {
		if ($first_item === true) {
			$first_item = false;
		} else {
			echo ",";
		}
		echo "{".
		     "id: '".$entry["id"]."',".
             "username: ".json_encode($entry["username"]).",".
             "galaxy: ".$entry["galaxy"].",".
             "counter: ".$entry["counter"].
             "}\n";
	}
?>
	]}

var store3 = new dojo.data.ItemFileReadStore({data: storeData3});
</script>
<table dojoType="dojox.grid.DataGrid" jsId="grid3" id="grid3" store="store3" query="{ username: '*' }" selectable="true"
			style="width: 100%; margin: 5 0 0 0;" clientSort="false" sortinfo="2" autoHeight="true" rowCount="<?php echo $number_of_items; ?>">
	<thead>
		<tr>
			<th width="auto" field="username"><?php echo USERINFO_USERNAME; ?></th>
			<th width="auto" field="galaxy"><?php echo USERINFO_GALAXY; ?></th>
			<th width="auto" field="counter"><?php echo USERINFO_SYSTEMS; ?></th>
		</tr>
	</thead>
</table><br>
